<?php

use think\migration\Seeder;

class SourcePollutantForecastData extends Seeder
{

    public function run()
    {
        $table = $this->table('source_bureau_air_quality_pollutant_forecast');
        $rows = [
            [
                'city_name'          => '长治',
                'station_short_name' => 'CZBZ',
                'data'               => $this->data(),
                'predict_time'       => date('Y-m-d H', time()) . ':00:00',   //预报时间-7天168小时
                'publish_time'       => date('Y-m-d H', time()) . ':00:00',   //发布时间-7天168小时
                'creat_time'        => date('Y-m-d H:i:s', time()),
                'is_to_tsinghua'     => '1',
            ],
        ];
        $table->insert($rows)->save();
    }

    public function data()
    {
        //注：数据库中取到提58万行数据，这里只取一部分
        $data = file_get_contents(__DIR__ . '/json/camx.json');
        return $data;
    }
}